home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Samples / SampleCode / Plug-in - WireFrame Renderer / SR_MacDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  17.9 KB  |  765 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        SR_MacDialog.c                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Modal dialog routines                                      **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1996-1997 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #include "QD3D.h"
  15. #include "QD3DExtension.h"
  16.  
  17. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  18.  
  19. #define BUILDING_FOR_SYSTEM7     1
  20.  
  21. #include <assert.h>
  22. #include <Dialogs.h>
  23. #include <Sound.h>
  24. #include <string.h>
  25. #include <Devices.h>
  26. #include <ToolUtils.h>
  27. #include <Aliases.h>
  28. #include <Resources.h>
  29. #include <TextUtils.h>
  30.  
  31. #include "SR.h"
  32. #include "SR_MacDialog.h"
  33.  
  34.  
  35. /******************************************************************************
  36.  **                                                                             **
  37.  **                                    Dialog ID's                                 **
  38.  **                                                                             **
  39.  *****************************************************************************/
  40.  
  41. #define SR_DLOG_ID            128
  42. #define SR_MOVABLE_DLOG_ID    129
  43. #define    SR_DLOG_OK            1
  44. #define    SR_DLOG_CANCEL        2
  45. #define    SR_DLOG_CHECKBOX    3
  46.  
  47.  
  48. /******************************************************************************
  49.  **                                                                             **
  50.  **                                Forward Declarations                         **
  51.  **                                                                             **
  52.  *****************************************************************************/
  53.  
  54. static TQ3Status SR_ModalDialog(
  55.     TQ3RendererObject    renderer,
  56.     TQ3Boolean            *canceled,    
  57.     void                *rendererPrivate);
  58.  
  59. static TQ3Status SR_MovableModalDialog(
  60.     TQ3RendererObject    renderer,
  61.     TQ3DialogAnchor     dialogAnchor, 
  62.     TQ3Boolean            *canceled,    
  63.     void                *rendererPrivate);
  64.     
  65. static DialogPtr SR_LoadDialog(
  66.     short                dlogId,
  67.     void                *rendererPrivate);
  68.  
  69. static TQ3Status HandleHit(
  70.     DialogPtr            dialog,
  71.     short                itemHit,
  72.     TQ3Boolean            *done,
  73.     TQ3RendererObject    renderer,
  74.     TQ3Boolean            *canceled,    
  75.     void                *rendererPrivate);
  76.     
  77. static TQ3Boolean HandledEvent(
  78.     EventRecord            *event,
  79.     DialogPtr            dialog,
  80.     short                *itemHit,
  81.     TQ3Boolean            *done,
  82.     TQ3RendererObject    renderer,
  83.     TQ3Boolean            *canceled,    
  84.     void                *rendererPrivate);
  85.  
  86. static void HandleMenuClick(
  87.     long                menuItem);
  88.  
  89. static void DrawDefaultButtonOutline(
  90.     DialogPtr            dialog,
  91.     short                item);
  92.  
  93. Boolean ModalDialogFilter(
  94.     DialogPtr            dialog,
  95.     EventRecord            *event,
  96.     short                *itemHit);
  97.  
  98. void SimulateButtonClick(
  99.     DialogPtr            dialog,
  100.     short                item);
  101.  
  102.  
  103. /******************************************************************************
  104.  **                                                                             **
  105.  **                                    Globals                                     **
  106.  **                                                                             **
  107.  *****************************************************************************/
  108.  
  109. static ModalFilterUPP     SRgModalFilterUPP = NULL;
  110.  
  111. /* 
  112.  * The next two statics are needed to set and reset the Resource chain prior to
  113.  * calling out to the applications Event handler
  114.  */
  115. static short            SRgOldResFile, 
  116.                         SRgResFile;
  117.  
  118. extern AliasHandle         SRgAliasHandle;
  119.  
  120.  
  121. /******************************************************************************
  122.  **                                                                             **
  123.  **                                Naming Routines                                 **
  124.  **                                                                             **
  125.  *****************************************************************************/
  126.  
  127. /*===========================================================================*\
  128.  *
  129.  *    Routine:    SR_GetNameString()
  130.  *
  131.  *    Comments:    
  132.  *
  133. \*===========================================================================*/
  134.  
  135. TQ3Status SR_GetNameString(
  136.     unsigned char                *dataBuffer, 
  137.     unsigned long                bufferSize,
  138.     unsigned long                *actualDataSize)
  139. {
  140.     TQ3Status    status = kQ3Success;
  141.     Boolean        wasChanged;
  142.     FSSpec        fileSpec;
  143.     OSErr        macErr;
  144.     Str255        tempBuffer;
  145.  
  146.     /*
  147.      * Get at the resource file for this renderer and open the resource
  148.      * file, locate the renderer name string and close the res file
  149.      * returning the string in the buffer we were passed.
  150.      */
  151.     SRgOldResFile = CurResFile();
  152.     
  153.     macErr = ResolveAlias(NULL, SRgAliasHandle, &fileSpec, &wasChanged);
  154.     
  155.     if (macErr == noErr) {
  156.         SRgResFile = FSpOpenResFile(&fileSpec, fsRdPerm);
  157.         
  158.         if (SRgResFile != -1) {
  159.             *actualDataSize = 0L;
  160.             GetIndString(tempBuffer, SR_NAME_RESOURCE, 1);
  161.             
  162.             /* trim the buffer if necessary */
  163.             *actualDataSize = (tempBuffer[0] > bufferSize) ? 
  164.                                     bufferSize : tempBuffer[0];
  165.             
  166.             if (dataBuffer != NULL)  {
  167.                 /* copy from the pascal str returned by the res mgr */
  168.                 memcpy(
  169.                     (char *)dataBuffer, 
  170.                     (char *) &tempBuffer[1],
  171.                     *actualDataSize );
  172.                     
  173.                 /* and terminate the string */
  174.                 dataBuffer[*actualDataSize] = '\0';
  175.             }
  176.  
  177.             CloseResFile(SRgResFile);
  178.             UseResFile(SRgOldResFile);
  179.         } else {
  180.             Q3XMacintoshError_Post(ResError());
  181.             status = kQ3Failure;
  182.         }
  183.     } else {
  184.         Q3XMacintoshError_Post(macErr);
  185.         status = kQ3Failure;
  186.     }
  187.     
  188.     if (status == kQ3Failure || ResError()) {
  189.         *actualDataSize = 0L;
  190.         dataBuffer = NULL;
  191.     }
  192.         
  193.                 
  194.     return (status);
  195. }
  196.  
  197.  
  198. /******************************************************************************
  199.  **                                                                             **
  200.  **                                Dialog Routines                                 **
  201.  **                                                                             **
  202.  *****************************************************************************/
  203.  
  204. /*===========================================================================*\
  205.  *
  206.  *    Routine:    SR_MacModalDialog()
  207.  *
  208.  *    Comments:    
  209.  *
  210. \*===========================================================================*/
  211.  
  212. TQ3Status SR_MacModalDialog(
  213.     TQ3RendererObject    renderer,
  214.     TQ3DialogAnchor     dialogAnchor, 
  215.     TQ3Boolean            *canceled,    
  216.     void                *rendererPrivate)
  217. {
  218.     TQ3Status    status;
  219.     Boolean        wasChanged;
  220.     FSSpec        fileSpec;
  221.     OSErr        macErr;
  222.     
  223.     SRgOldResFile = CurResFile();
  224.     
  225.     macErr = ResolveAlias(NULL, SRgAliasHandle, &fileSpec, &wasChanged);
  226.     
  227.     if (macErr == noErr) {
  228.         SRgResFile = FSpOpenResFile(&fileSpec, fsRdPerm);
  229.         
  230.         if (SRgResFile != -1) {
  231.             if (dialogAnchor.clientEventHandler == NULL) {
  232.                 status = SR_ModalDialog(renderer, canceled, rendererPrivate);
  233.             } else {
  234.                 status = SR_MovableModalDialog(
  235.                             renderer, 
  236.                             dialogAnchor, 
  237.                             canceled, 
  238.                             rendererPrivate);
  239.             }
  240.             CloseResFile(SRgResFile);
  241.             UseResFile(SRgOldResFile);
  242.         } else {
  243.             Q3XMacintoshError_Post(ResError());
  244.             return (kQ3Failure);
  245.         }
  246.     } else {
  247.         Q3XMacintoshError_Post(macErr);
  248.         status = kQ3Failure;
  249.     }
  250.                     
  251.     return (status);
  252. }
  253.  
  254.  
  255. /*===========================================================================*\
  256.  *
  257.  *    Routine:    SR_MacModalDialog()
  258.  *
  259.  *    Comments:    
  260.  *
  261. \*===========================================================================*/
  262.  
  263. TQ3Status SR_ModalDialog(
  264.     TQ3RendererObject            renderer,
  265.     TQ3Boolean                    *canceled,    
  266.     void                        *rendererPrivate)
  267. {
  268.     DialogPtr    dialog;
  269.     short        itemHit;
  270.     TQ3Boolean    done = kQ3False;
  271.     TQ3Status    status = kQ3Success;
  272.     
  273.     if (SRgModalFilterUPP == NULL) {
  274.         SRgModalFilterUPP = NewModalFilterProc(ModalDialogFilter);
  275.     }
  276.     
  277.     if (SRgModalFilterUPP == NULL) {
  278.         Q3XMacintoshError_Post(MemError());
  279.         return (kQ3Failure);
  280.     }
  281.  
  282.     dialog = SR_LoadDialog(SR_DLOG_ID, rendererPrivate);
  283.     
  284.     if (dialog != NULL) {
  285.         do {
  286.             ModalDialog(SRgModalFilterUPP, &itemHit);
  287.             HandleHit(
  288.                 dialog, itemHit, &done, renderer, canceled, rendererPrivate);
  289.         } while (done == kQ3False);
  290.         
  291.         DisposeDialog(dialog);
  292.     } else {
  293.         Q3XMacintoshError_Post(ResError());
  294.         status = kQ3Failure;
  295.     }
  296.             
  297.     return (status);
  298. }
  299.  
  300.  
  301. /*===========================================================================*\
  302.  *
  303.  *    Routine:    ModalDialogFilter()
  304.  *
  305.  *    Comments:    
  306.  *
  307. \*===========================================================================*/
  308.  
  309. Boolean ModalDialogFilter(
  310.     DialogPtr        dialog,
  311.     EventRecord        *event,
  312.     short            *itemHit)
  313. {
  314.     Boolean        handled = kQ3False;
  315.     char        key;
  316.     long        menuItem;
  317.  
  318.     switch (event->what) {
  319.         case keyDown: {
  320.             key = (char) (event->message & charCodeMask);
  321.             if (key == '\r' || key == '\3') {
  322.                 *itemHit = SR_DLOG_OK;
  323.                 handled = kQ3True;
  324.                 SimulateButtonClick(dialog, SR_DLOG_OK);
  325.             } else if (key == '\33' || 
  326.                        ((event->modifiers & cmdKey) && key == '.')) {
  327.                 *itemHit = SR_DLOG_CANCEL;
  328.                 handled = kQ3True;
  329.                 SimulateButtonClick(dialog, SR_DLOG_CANCEL);
  330.             } else if (event->modifiers & cmdKey) {
  331.                 menuItem = MenuKey(key);
  332.                 if (menuItem) {
  333.                     HandleMenuClick(menuItem);
  334.                     handled = kQ3True;
  335.                 }
  336.             }
  337.             break;
  338.         }
  339.         case updateEvt: {
  340.             if ((DialogPtr) (event->message) == dialog) {
  341.                 DrawDefaultButtonOutline(dialog, SR_DLOG_OK);
  342.             }
  343.             break;
  344.         }
  345.     }
  346.     
  347.     return (handled);
  348. }
  349.  
  350.  
  351. /*===========================================================================*\
  352.  *
  353.  *    Routine:    DrawDefaultButtonOutline()
  354.  *
  355.  *    Comments:    
  356.  *
  357. \*===========================================================================*/
  358.  
  359. void DrawDefaultButtonOutline(
  360.     DialogPtr    dialog,
  361.     short        item)
  362. {
  363.     short        iType;
  364.     Rect        iRect;
  365.     Handle        iHandle;
  366.     GrafPtr        oldPort;
  367.     PenState    oldPenState;
  368.     short        buttonOval;
  369.     
  370.     GetDialogItem(dialog, item, &iType, &iHandle, &iRect);
  371.     
  372.     GetPort(&oldPort);
  373.     SetPort((**((ControlHandle) iHandle)).contrlOwner);
  374.     
  375.     GetPenState(&oldPenState);
  376.     PenNormal();
  377.     
  378.     InsetRect(&iRect, -4, -4);
  379.     FrameRoundRect(&iRect, 16, 16);
  380.     buttonOval = (iRect.bottom - iRect.top) / 2 + 2;
  381.     
  382.     PenSize(3, 3);
  383.     
  384.     FrameRoundRect(&iRect, buttonOval, buttonOval);
  385.     
  386.     SetPenState(&oldPenState);
  387.     SetPort(oldPort);
  388. }
  389.  
  390.  
  391. /*===========================================================================*\
  392.  *
  393.  *    Routine:    SR_MacModalDialog()
  394.  *
  395.  *    Comments:    
  396.  *
  397. \*===========================================================================*/
  398.  
  399. TQ3Status SR_MovableModalDialog(
  400.     TQ3RendererObject            renderer,
  401.     TQ3DialogAnchor             dialogAnchor, 
  402.     TQ3Boolean                    *canceled,    
  403.     void                        *rendererPrivate)
  404. {
  405.     DialogPtr        dialog, whichDlog;
  406.     short            itemHit;
  407.     TQ3Boolean        done = kQ3False, handled = kQ3False;
  408.     EventRecord        event;
  409.  
  410.     dialog = SR_LoadDialog(SR_MOVABLE_DLOG_ID, rendererPrivate);
  411.     
  412.     if (dialog == NULL) {
  413.         Q3XMacintoshError_Post(ResError());
  414.         return (kQ3Failure);
  415.     }
  416.         
  417.     do {
  418.         /* 
  419.          *  If your dialog handles DiskEvents then include it in the EventMask 
  420.          *    The extra test (event.what == nullEvent) is so we can pass on null
  421.          *    events to the app so it can do background processing.
  422.          */
  423.         if (WaitNextEvent(everyEvent & ~diskMask, &event, 1, NULL) ||
  424.             (event.what == nullEvent)) {
  425.             if (HandledEvent(
  426.                     &event, 
  427.                     dialog, 
  428.                     &itemHit, 
  429.                     &done, 
  430.                     renderer, 
  431.                     canceled, 
  432.                     rendererPrivate) == kQ3False) {
  433.                 if (IsDialogEvent(&event)) {
  434.                     /*
  435.                      *    This is kind of wierd. If the event is a nullevent
  436.                      *    then we want to give the dialog and the app a shot at
  437.                      *    handling it. Hence the next statement.
  438.                      */
  439.                     handled = (TQ3Boolean) (event.what != nullEvent);    
  440.                     if (DialogSelect(&event, &whichDlog, &itemHit) && 
  441.                             whichDlog == dialog) {
  442.                         HandleHit(
  443.                             dialog, 
  444.                             itemHit, 
  445.                             &done, 
  446.                             renderer, 
  447.                             canceled, 
  448.                             rendererPrivate);
  449.                     }
  450.                 }
  451.                 
  452.                 if (!handled) {
  453.                     /* 
  454.                      *  At this point we have checked for all events
  455.                      *  that we are interested in. Give the app a shot
  456.                      *  at the event 
  457.                      *
  458.                      *  Restore the old Resource file ordering 
  459.                      */
  460.                     UseResFile(SRgOldResFile);
  461.                     
  462.                     /* 
  463.                      *  The app's event-handler 
  464.                      */
  465.                     (dialogAnchor.clientEventHandler)(&event);
  466.                     
  467.                     /* 
  468.                      *  Call me paranoid, but just in case the app
  469.                      * opens another resource file 
  470.                      */
  471.                     SRgOldResFile = CurResFile();
  472.                     
  473.                     /* 
  474.                      *  Set it back to ours
  475.                       */
  476.                     UseResFile(SRgResFile);
  477.                 }
  478.             }
  479.         }
  480.     } while (done == kQ3False);
  481.     
  482.     DisposeDialog(dialog);
  483.         
  484.     return (kQ3Success);
  485. }
  486.  
  487.  
  488. /*===========================================================================*\
  489.  *
  490.  *    Routine:    SR_LoadDialog()
  491.  *
  492.  *    Comments:    
  493.  *
  494. \*===========================================================================*/
  495.  
  496. DialogPtr SR_LoadDialog(
  497.     short    dlogId,
  498.     void    *rendererPrivate)
  499. {
  500.     short        iType, checkBoxVal;
  501.     Rect        iRect;
  502.     Handle        iHandle;
  503.     DialogPtr    dialog;
  504.     
  505.     dialog = GetNewDialog(dlogId, NULL, (WindowPtr) -1);
  506.     GetDialogItem(dialog, SR_DLOG_CHECKBOX, &iType, &iHandle, &iRect);
  507.     
  508.     checkBoxVal = ((TSRPrivate *) rendererPrivate)->dummyConfigData;
  509.     SetControlValue((ControlHandle) iHandle, checkBoxVal);
  510.     
  511.     ShowWindow(dialog);
  512.     
  513.     return (dialog);
  514. }
  515.  
  516.  
  517. /*===========================================================================*\
  518.  *
  519.  *    Routine:    HandledEvent()
  520.  *
  521.  *    Comments:    
  522.  *
  523. \*===========================================================================*/
  524.  
  525. TQ3Boolean HandledEvent(
  526.     EventRecord                *event,
  527.     DialogPtr                dialog,
  528.     short                    *itemHit,
  529.     TQ3Boolean                *done,
  530.     TQ3RendererObject        renderer,
  531.     TQ3Boolean                *canceled,    
  532.     void                    *rendererPrivate)
  533. {
  534.     short            part;
  535.     WindowPtr        whichWindow;
  536.     TQ3Boolean        handled = kQ3False;
  537.     char            key;
  538.     long            menuItem;
  539.     
  540.     switch (event->what) {
  541.         case mouseDown:
  542.             part = FindWindow(event->where, &whichWindow);
  543.             switch (part) {
  544.                 case inDrag: {
  545.                     handled = kQ3True;
  546.                     if (whichWindow == dialog) {
  547.                         DragWindow(
  548.                             dialog, 
  549.                             event->where, 
  550.                             &((*GetGrayRgn())->rgnBBox));
  551.                     } else {
  552.                         SysBeep(30);
  553.                     }
  554.                     break;
  555.                 }
  556.                 case inContent:
  557.                 case inGrow:
  558.                 case inGoAway:
  559.                 case inZoomIn:
  560.                 case inZoomOut: {        
  561.                     if (whichWindow != dialog) {
  562.                         handled = kQ3True;
  563.                         SysBeep(30);
  564.                     }
  565.                     break;
  566.                 }
  567.                 case inMenuBar: {
  568.                     handled = kQ3True;
  569.                     menuItem = MenuSelect(event->where);
  570.                     HandleMenuClick(menuItem);
  571.                     break;
  572.                 }                
  573.             }
  574.             break;
  575.         case keyDown: {
  576.             key = (char) (event->message & charCodeMask);
  577.             if (key == '\r' || key == '\3') {
  578.                 *itemHit = SR_DLOG_OK;
  579.                 handled = kQ3True;
  580.                 SimulateButtonClick(dialog, SR_DLOG_OK);
  581.                 HandleHit(
  582.                     dialog, *itemHit, done, renderer, canceled, rendererPrivate);
  583.             } else if (key == '\33' || 
  584.                       ((event->modifiers & cmdKey) && key == '.')) {
  585.                 *itemHit = SR_DLOG_CANCEL;
  586.                 handled = kQ3True;
  587.                 SimulateButtonClick(dialog, SR_DLOG_CANCEL);
  588.                 HandleHit(
  589.                     dialog, *itemHit, done, renderer, canceled, rendererPrivate);                
  590.             } else if (event->modifiers & cmdKey) {
  591.                 menuItem = MenuKey(key);
  592.                 if (menuItem) {
  593.                     HandleMenuClick(menuItem);
  594.                     handled = kQ3True;
  595.                 }
  596.             }
  597.             break;
  598.         }
  599.         case updateEvt: {
  600.             if ((DialogPtr) (event->message) == dialog) {
  601.                 DrawDefaultButtonOutline(dialog, SR_DLOG_OK);
  602.             }
  603.             break;
  604.         }
  605.     }
  606.     
  607.     return (handled);
  608. }
  609.  
  610.  
  611. /*===========================================================================*\
  612.  *
  613.  *    Routine:    HandleMenuClick()
  614.  *
  615.  *    Comments:    
  616.  *
  617. \*===========================================================================*/
  618.  
  619. void HandleMenuClick(
  620.     long    menuItem)
  621. {
  622.     short             item = LoWord(menuItem);
  623.     short            menu = HiWord(menuItem);
  624.     MenuHandle        menuH;
  625.     Str255            itemText;
  626.  
  627.     if (menuItem)  {
  628.         menuH = GetMenuHandle(menu);
  629.         GetMenuItemText(menuH, item, itemText);
  630.         
  631.         /* 
  632.          *    This is ugly.
  633.          *  We compare names of the menus because we don't know what the
  634.          *  application's Menu IDs are. I am using constant strings this will
  635.          *    not work on non English systems. You should proabably load some 
  636.          *    STR resources and compare against them so that the Renderer can be
  637.          *    localized.
  638.          */
  639.         if (strncmp((char *) (**menuH).menuData, (char *) "\pEdit", 5) == 0) {
  640.             if (strncmp((char *) itemText, (char *) "\pUndo", 5) == 0) {
  641.                 /* 
  642.                  *  Handle Undo if supported 
  643.                  */
  644.             } else if (strncmp((char *) itemText, (char *) "\pCut", 4) == 0) {
  645.                 /* 
  646.                  *  Handle Cut if supported - use DialogCut 
  647.                  */
  648.             } else if (strncmp((char *) itemText, (char *) "\pCopy", 5) == 0) {
  649.                 /* 
  650.                  *  Handle Copy if supported - use DialogCopy
  651.                  */
  652.             } else if (strncmp((char *) itemText, (char *) "\pPaste", 6) == 0) {
  653.                 /* 
  654.                  *  Handle Paste if supported - use DialogPaste
  655.                  */
  656.             } else if (strncmp((char *) itemText, (char *) "\pClear", 6) == 0) {
  657.                 /* 
  658.                  *  Handle Clear if supported 
  659.                  */
  660.             } else {
  661.                 /* 
  662.                  *  Nothing else should be selectable in the Edit Menu
  663.                  *  The calling application should have disabled all others
  664.                  *  SysBeep or Alert to notify user of error 
  665.                  */
  666.                 SysBeep(30);
  667.             }
  668.         } else if (strncmp(
  669.                     (char *) (**menuH).menuData, 
  670.                     (char *) "\x01\x14", 2) == 0) {
  671.             /* 
  672.              *  Apple menu was selected. All application specific items
  673.              *  in the Apple Menu such as "About..." should have been
  674.              *  disabled by the app 
  675.              */
  676.             OpenDeskAcc(itemText);
  677.         } else {
  678.             /* 
  679.              *  No other menu should be selectable
  680.              *  The calling application should have disabled all others
  681.              *  SysBeep or Alert to notify user of error 
  682.              */
  683.             SysBeep(30);
  684.         }
  685.         HiliteMenu(0);
  686.     }
  687. }
  688.  
  689.  
  690. /*===========================================================================*\
  691.  *
  692.  *    Routine:    HandleHit()
  693.  *
  694.  *    Comments:    
  695.  *
  696. \*===========================================================================*/
  697.  
  698. TQ3Status HandleHit(
  699.     DialogPtr                    dialog,
  700.     short                        itemHit,
  701.     TQ3Boolean                    *done,
  702.     TQ3RendererObject            renderer,
  703.     TQ3Boolean                    *canceled,    
  704.     void                        *rendererPrivate)
  705. {
  706.     short        iType, checkBoxVal;
  707.     Rect        iRect;
  708.     Handle        iHandle;
  709.     
  710.     UNUSED(renderer);
  711.  
  712.     switch (itemHit) {
  713.         case SR_DLOG_OK:
  714.             GetDialogItem(dialog, SR_DLOG_CHECKBOX, &iType, &iHandle, &iRect);
  715.             ((TSRPrivate *) rendererPrivate)->dummyConfigData = 
  716.                 GetControlValue((ControlHandle) iHandle);
  717.             *done = kQ3True;
  718.             *canceled = kQ3False;
  719.             break;
  720.         case SR_DLOG_CANCEL:
  721.             *done = kQ3True;
  722.             *canceled = kQ3True;
  723.             break;
  724.         case SR_DLOG_CHECKBOX:
  725.             GetDialogItem(dialog, SR_DLOG_CHECKBOX, &iType, &iHandle, &iRect);
  726.             checkBoxVal = GetControlValue((ControlHandle) iHandle);
  727.             SetControlValue((ControlHandle) iHandle, !checkBoxVal);
  728.             break;            
  729.     }
  730.     
  731.     return (kQ3Success);
  732. }
  733.  
  734.  
  735. /*===========================================================================*\
  736.  *
  737.  *    Routine:    SimulateButtonClick()
  738.  *
  739.  *    Comments:    
  740.  *
  741. \*===========================================================================*/
  742.  
  743. void SimulateButtonClick(
  744.     DialogPtr    dialog,
  745.     short        item)
  746. {
  747.     short        iType;
  748.     Rect        iRect;
  749.     Handle        iHandle;
  750.     long        ticks;
  751.  
  752.     GetDialogItem(dialog, item, &iType, &iHandle, &iRect);
  753.     HiliteControl((ControlHandle) iHandle, kControlButtonPart);
  754.     ticks = TickCount() + 8;
  755.     
  756.     while (TickCount() < ticks) {
  757.         /*
  758.          *  Spin...
  759.          */
  760.     }
  761.     HiliteControl((ControlHandle) iHandle, 0);    
  762. }
  763.  
  764. #endif  /*  WINDOW_SYSTEM_MACINTOSH  */
  765.